function LookupInstructor(ev) {
  ev.preventDefault()
  var input = $(this);
  var form = $(this).parents('form');
  var data = new Array();
  data.push({name: input.attr('name'), value: input.val()});
  $.post('/instructor', data, function(json) {
    if (json.instructor != null) {
      $(form).find('input[name=instructor]').val(json.instructor);
    }
    if (json.cert != null) {
      $(form).find('input[name=cert]').val(json.cert);
    }
    if (json.expiration != null) {
      $(form).find('input[name=expiration]').val(json.expiration);
    }
    if (json.signature != null) {
      $(form).find('input[name=signature]').val(json.signature);
      $(form).signaturePad().regenerate(json.signature);
    }
  }, 'json');
}


function registerDeleteConfirmation(postUri) {
  $('.delete').click(function(ev) {
    var modelKey = $(this).val();
    $('#delete-button').val(modelKey);
    $('#confirm').modal('show');
  });
  $('#delete-button').click(function() {
    var modelKey = $(this).val();
    var selector = '#' + modelKey;
    console.log('Deleting Model: ' + modelKey);
    $.post(postUri, {delete: modelKey})
        .done(function() {
          $(selector).remove();
          $('#confirm').modal('hide');
        });
  });
};

